package com.lingyi.algorithm.lab2;

/**
 * 题目1:找出链表中的倒数第k的数
 * @author chenweilong
 * @email 1433471850@qq.com
 * @date 2020-08-20 10:36
 */
public class Topic1 {


    public static void main(String[] args) {

        Node<Integer> node = MergeLinkList.initNode(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

        int k = 2;

        Node<Integer> kz = node;
        Node<Integer> mz = node;

        for (int i = 0; i < k - 1; i++) {
            kz = kz.getNext();
        }

        while (kz != null && kz.getNext() != null) {
            kz = kz.getNext();
            mz = mz.getNext();
        }

        System.out.println(mz.getT());


    }


}
